package com.ruoyi.produce.process.parameter.service;

import com.ruoyi.produce.process.parameter.domain.ProcessParameter;
import com.ruoyi.produce.process.parameter.mapper.ProcessParameterMapper;
import com.ruoyi.produce.process.worksheet.domain.ProduceWorkSheet;
import com.ruoyi.produce.process.worksheet.service.IProduceWorkSheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProcessParameterServiceImpl implements IProcessParameterService{
    @Autowired
    private ProcessParameterMapper processParameterMapper;
    @Autowired
    private IProduceWorkSheetService workSheetService;

    /**
     * 查询
     * @param processParameter
     * @return
     */
    @Override
    public List<ProcessParameter> selectProcessParameterList(ProcessParameter processParameter) {
        List<ProcessParameter> processParameterList = processParameterMapper.selectProcessParameterList(processParameter);
        for (ProcessParameter item : processParameterList) {
            ProduceWorkSheet workSheet = workSheetService.selectProduceWorkSheetById(item.getWorkSheetId());
            item.setProduceName(workSheet.getProduceName());
        }
        return processParameterList;
    }

    /**
     * 根据id查
     * @param workSheetId
     * @return
     */
    @Override
    public ProcessParameter selectProcessParameterById(String workSheetId) {
        return processParameterMapper.selectProcessParameterById(workSheetId);
    }

    /**
     * 新增
     *
     * @param processParameter
     * @return
     */
    @Override
    public int insertProcessParameter(ProcessParameter processParameter) {
        return processParameterMapper.insertProcessParameter(processParameter);
    }

    /**
     * 修改
     * @param processParameter
     * @return
     */
    @Override
    public int updateProcessParameter(ProcessParameter processParameter) {
        return processParameterMapper.updateProcessParameter(processParameter);
    }

    /**
     * 删除
     * @param processParameter
     * @return
     */
    @Override
    public int deleteProcessParameter(ProcessParameter processParameter) {
        return processParameterMapper.deleteProcessParameter(processParameter);
    }
}
